package com.shujia.flink.tf;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Demo2MapJava {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> studentsDS = env.readTextFile("data/students.txt");


/*        DataStream<String> mapDS = studentsDS.map(new MapFunction<String, String>() {
            @Override
            public String map(String value) throws Exception {
                return value.split(",")[4];
            }
        });*/

        DataStream<String> mapDS = studentsDS.map((MapFunction<String, String>) value -> value.split(",")[4]);




        mapDS.print();


        env.execute();

    }
}
